<template>
  <div class="index_container">
    <my-logo></my-logo>
    <my-banner :banner="bannerList"></my-banner>
    <nav-bar></nav-bar>
    <my-new :roll="rollList"></my-new>
    <my-select :select="selectList"></my-select>
    <my-recommend :bast="bastObj.bastList" :banner="bastObj.bastbanner"></my-recommend>
    <hot-rank :likeInfo="likeInfo"></hot-rank>
    <new-goods :firstList="firstList"></new-goods>
    <pro-goods :benefit="benefitList"></pro-goods>
  </div>
</template>

<script>
import config from "@/utils/config";
import NavBar from "@/views/index/navbar/NavBar.vue";
import MyLogo from "@/views/index/logo/MyLogo.vue";
import MyNew from "@/views/index/new/MyNew.vue";
import MyBanner from "@/views/index/banner/MyBanner.vue"
import MySelect from "@/views/index/select/MySelect.vue"
import MyRecommend from "@/views/index/recommend/MyRecommend.vue"
import HotRank from "@/views/index/rank/HotRank.vue"
import NewGoods from "@/views/index/newgoods/NewGoods.vue"
import ProGoods from "@/views/index/pro/ProGoods.vue"


export default {
  name: "Index",
  data(){
      return{
          bannerList:[],
          rollList:[],
          selectList:[],
          bastObj:{},
          benefitList:[],
          likeInfo:[],
          firstList:[],
      }
  },
  components: {
    NavBar,
    MyLogo,
    MyNew,
    MyBanner,
    MySelect,
    MyRecommend,
    ProGoods,
    HotRank,
    NewGoods,
  },
  created() {
    // document.querySelector("body").style.backgroundColor = "#fff";
    this.initData()
  },
  methods:{
      initData(){
          let url = "/api/index"
          let pro = axios.get(url).then(response=>{
              let {status,data} = response.data
              
              if(status == 200 ){
                  // 结构data中数据
                  let { banner,roll,info,benefit,likeInfo } = data
                  this.bannerList = banner
                  this.rollList = roll
                  this.selectList = info.fastList
                  this.bastObj.bastbanner = info.bastBanner
                  this.bastObj.bastList = info.bastList
                  this.benefitList = benefit
                  this.likeInfo = likeInfo
                  this.firstList = info.firstList
              }

              console.log("获取首页数据成功",status)
          }).catch(err=>{
              console.log("获取首页数据失败")
          })
      }
  },
  mounted() {},
  beforeCreate() {},
};
</script>
<style lang="scss" scoped>
.index_container{
    padding-bottom: 70px;
}
</style>